<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Document</title>
	<script type="text/javascript" src='./Public/jquery-1.8.2.min.js'></script>
	<link rel="stylesheet" href="./Public/bootstrap.css" />
	<link rel="stylesheet" href="__PUBLIC__/Css/common.css" />

	<style type="text/css">
		body{
			margin-bottom: 100px;
		}
	</style>
	<script src="Public/Admin/jquery-1.8.2.min.js" type="text/javascript" charset="utf-8"></script>
	    <script type="text/javascript">
	    	/*$(function(){
	    		
	    		//抓取表单提交事件
	    		$('.add').submit(function(){
	    			//抓取表单的所有数据
	    			var formData=$(this).serialize();				
	    			//发送异步
	    			$.ajax({
	    				type:"post",
	    				url:"<?php echo U('add')?>",
	    				data:formData,
	    				dataType:'json',
	    				success:function(formData){
	    					
	    				    var path = '<?php echo U("edit")?>&bid='+formData.bid;
	    					var str='<tr class="addr info">';
								str+='<td>'+formData.bid+'</td>';
								$.each(formData.bbid,function(i,n){
								str+='<td>'+n+'</td>';
								});
								   //庫存
							str+='<td>'+formData.ginventory+'</td>';
								//貨號
							str+='<td>'+formData.gart+'</td>';
							 
									str+='<td><a href="'+path+'"  class="btn btn-sm btn-warning edit">编辑</a>';
									str+='<a href="javascript:;" bid="'+formData.bid+'" class="btn btn-sm btn-danger del">删除</a></td></tr>';
								
							$('.addr:last').after(str);
								
							
	    				}
	    			});
	    			//阻止表单提交
	    			return false;
	    		})
	    		
	    		//异步删除  添加未来事件
	    		$('.del').live('gclick',function(){
	    			var bid=$(this).attr('bid');
	    			if(confirm('确认删除么？')){
		    			$.ajax({
		    				type:'post',
		    				url:"<?php echo U('del')?>",
		    				data:{bid:bid},
		    				dataType:'json',
		    				success:function(bid){
		    				}
		    			})
		    			$(this).parents('tr').remove();
		    		}
		    		
	    		})
	    	})*/
	    </script>
</head>
<body>
	<div class="container-fluid">
	<div class="row-fluid">
	<div class="span12">

	<if condition="$is_show">

	</if>
		<table class='table table-bordered table-hover'>
			<tr>
				<th>货品ID</th>
				 <?php foreach ($name as $k=>$v){?>
				  		<th ><?php echo $v?></th>
			    <?php }?>
				<th>库存</th>
				<th>货号</th>
				<th>操作</th>
			</tr>
			
			
			<?php foreach ($newData as $v){?>
			<tr class="info addr">
				<td><?php echo $v['goods']['bid']?></td>
				<?php foreach ($v['value'] as $vv){?>
				<td><?php echo $vv['gtvalue']?></td>
				<?php }?>
				<td><?php echo $v['goods']['gart']?></td>
				<td><?php echo $v['goods']['ginventory']?></td>
				<td>
					<a href="<?php echo U('edit',array('bid'=>$v['goods']['bid']))?>" class="btn btn-sm btn-success edit">編輯</a>
					<a href="<?php echo U('del',array('bid'=>$v['goods']['bid']))?>" class="btn btn-sm btn-danger del">删除</a>
				</td>
			</tr>
			<?php }?>
				
			<form class="" action="<?php echo U('add')?>" method='post'>	
			<!-- 如果已添加数目小于可能情况数目，才出现添加货品的输入框 -->
			<if condition="$is_show">		
			<tr class="info">
			
			<td>添加货品</td>
		        <?php foreach ($types as $k=>$v){?>
					<td>
						<select name="bbid[]" class="form-control">
							<option value="">
								请选择
							</option>
							<?php foreach ($v as $b){?>
							<option value="<?php echo $b['gaid']?>"><?php echo $b['gtvalue']?></option>
							<?php }?>
						</select>
					</td>
				<?php }?>
				<td>
					<input type="text" name='gart' value=""/>
				</td>
				<td>
					<input type="text" name='ginventory' value="" />
				</td>
				<td></td>
			</tr>
			</if>
		</table>

	<if condition="$is_show">
		<input type="hidden" name="goods_gid" value="<?php echo $_GET['gid']?>"/>
		<input type="submit" value='保存添加' class="btn btn-primary"/>
	</if>
	</form>

	</div>
	</div>
	</div>



</body>
</html>